<html>
<head>
    <meta name="layout" content="freshmade">
</head>

<body>

<div id="content-wrapper">
    <div class="center-wrapper">
        <div class="content">
            <div id="main">
                <div class="post">
                    <div class="post-title">
                        <h1><tmpl:/expenseDetail/expenseGroupOfOwner noLink="true"/></h1>
                        <g:render template="/template/messageBar"/>
                    </div>

                    <div class="post-button">
                        <g:render template="/template/editdelete"/>
                    </div>

                    <div class="post-date">
                        <g:render template="/template/createdBy2" model="[trace: expenseGroup]"/>
                    </div>
                </div>

                <div id="myform">

                    <div class="field">
                        <div class="key2"><g:message code="expenseGroup.type"/></div>

                        <div class="value">${expenseGroup.type}</div>

                        <div class="clear"></div>
                    </div>

                    <div class="field">
                        <div class="key2"><g:message code="expenseGroup.status"/></div>

                        <div class="value">${expenseGroup.status}</div>

                        <div class="clear"></div>
                    </div>


                    <div class="field">
                        <div class="key2"><g:message code="expenseGroup.approved"/></div>

                        <div class="value">
                            <g:if test="${expenseGroup.approvedBy}">
                                ${expenseGroup.approvedBy.name} on
                                <g:formatDate date="${expenseGroup.approvedDate}"/>
                            </g:if>
                            <g:else>
                                <g:link action="approve" id="${expenseGroup.id}">Approve...</g:link>
                            </g:else>
                        </div>

                        <div class="clear"></div>
                    </div>


                    <div class="field">
                        <div class="key2"><g:message code="expenseGroup.writeoff"/></div>

                        <div class="value">
                            <g:if test="${expenseGroup.writeoffBy}">
                                ${expenseGroup.writeoffBy.name} on
                                <g:formatDate date="${expenseGroup.writeoffDate}"/>
                            </g:if>
                            <g:else>
                                <g:link action="writeoff" id="${expenseGroup.id}">WriteOff...</g:link>
                            </g:else>
                        </div>

                        <div class="clear"></div>
                    </div>
                </div>

                <br/>

                <div class="post">
                    <div class="post-title"><h3><g:message code="expense.detail"/></h3></div>

                    <div class="post-date">
                        <g:render template="/template/listBar2" model="[size: expenseGroup.expenseDetails.size()]"/>
                        | <g:link controller="expenseDetail" action="create" id="${expenseGroup.id}">
                            Add Detail...</g:link>
                        | <g:link controller="expenseDetail" action="upload" id="${expenseGroup.id}">
                            Upload Detail...</g:link>
                    </div>

                </div>
                <table class="data-table">
                    <tr>
                        <th><g:message code="expenseDetail.payDate"/></th>
                        <th><g:message code="expenseDetail.payAmount"/></th>
                        <th><g:message code="expenseDetail.payFor"/></th>
                    </tr>
                    <tbody>
                    <g:each in="${expenseGroup.expenseDetails}" status="i" var="e">
                        <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
                            <td><g:link controller="expenseDetail" action="show" id="${e.id}">
                                <g:formatDate date="${e.payDate}" formatName="date.format.day"/>
                            </g:link></td>
                            <td>${e.payAmount}</td>
                            <td>${e.payFor}</td>
                        </tr>
                    </g:each>
                    <tr>
                        <th></th>
                        <th>${sumPayAmount}</th>
                        <th></th>
                    </tr>
                    </tbody>
                </table>
            </div>

            <div class="clearer">&nbsp;</div>
        </div>

    </div>
</div>

</body>
</html>